package com.didispace.web;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.didispace.aspect.AopAccess;
import com.didispace.aspect.MyException;

/**
 * @author wuyanzu
 * @version 1.0.0
 * @date 18/5/2 上午10:50.
 * @blog https://www.cnblogs.com/7motor28/
 */
@RestController
public class HelloController {
	
	/*@Autowired
	private RedisTemplate<String, Object> redisTemplate;*/
	
    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    @ResponseBody
    @AopAccess(desc="hello")
    public String hello(@RequestParam String name) throws Exception{
    	//redisTemplate.opsForValue().set(System.currentTimeMillis()+"", name);
        return "Hello " + name;
    }
    
    @RequestMapping(value = "/helloW", method = RequestMethod.GET)
    @ResponseBody
    @AopAccess(desc="helloW")
    public String helloW(@RequestParam String name) throws MyException{
    	try{
    		System.out.println(Integer.valueOf(name));
    	}catch(Exception e){
    		throw new MyException("转换错误");
    	}
        return "Hello " + name;
    }

}
